<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="../../../Themes/default/easyui.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/gray/window.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/demo.css">
		<link rel="stylesheet" type="text/css" href="../../../CSS/common.css">
		<link rel="stylesheet" type="text/css" href="../../../Themes/icon.css" />
		<script type="text/javascript" src="../../../JS/jquery.min.js"></script>
		<script type="text/javascript" src="../../../JS/jquery.easyui.min.js"></script>
		<script type="text/javascript" src="../../../JS/common.js"></script>
		<script type="text/javascript" src="../../../JS/SHA-1.js"></script>
		<script type="text/javascript" src="../../../JS/BasicInfomation.js"></script>
	</head>

	<body style="padding: 0px;">
		<div style="width: 400px;">
			<form id="ff" method="post">
				<br />
				<table cellpadding="3" class="displaytable" style="margin-left: 40px;padding: 30px;">
					<tr>
						<td width="35%">
							<h id="star">* </h>内部商品分类</td>
						<td width="65%">
							<input id="cc" style="width:84%" class="easyui-combobox" name="INTERNAL_TYPE" editable="fasle" data-options="panelHeight:'100px',required:true,url:RemoteLinkAddress+'/logistics/internaltradetype/listall.do ',method:'get',valueField:'INTERNAL_TYPE',textField:'INTERNAL_TYPE'"></input>
							<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="AddInsideProductTypeName()"></a>
						</td>
					</tr>
					<tr>
						<td>
							<h id="star">* </h>内部产品名称</td>
						<td><input style="width:100%" class="easyui-textbox" name="INTERNAL_NAME" data-options="required:true"></input>
						</td>
					</tr>
					<tr>
						<td>
							<h id="star">* </h>计量单位</td>
						<td><input style="width:100%" class="easyui-textbox" name="UNIT_NAME" data-options="required:true"></input>
						</td>
					</tr>
					<tr class="hiddentr">
						<td>ID</td>
						<td><input style="width:100%" class="easyui-textbox" name="ID"></input>
						</td>
					</tr>
				</table>
				<table>
					<div class="submit_button" style="margin-left: 45px;">
						<a class="easyui-linkbutton" onclick="save()" style="width: 100px;"> 保存</a>
					<a class="easyui-linkbutton" onclick="cls()" style="width: 100px;margin-left: 10px;">清空 </a>
					</div>
				</table>
			</form>
			<div id="dlg" class="easyui-dialog" closed="true" style="width:560px;height:400px;padding:10px">
				<iframe id="ifrmEdit" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>
			</div>
		</div>
	</body>
	<script type="text/javascript">
		var id = getID();
		var AddDialog;
		$(document).ready(function(){
			if(id != AddFlag) {
			loadRemote();
		}
		});
		

		function save() {
			SaveData();
		}

		function loadRemote() {
			$('#ff').form('load', RemoteLinkAddress + '/logistics/internaltrade/findbyid.do?ID=' + id);
		}

		function cls() {
			$('#ff').form('reset');
		}
		var auth = "admin;" + hex_sha1("admin1");

		function SaveData() {
			var _url = "";
			data = $('#ff').serialize();
			if(id == AddFlag) {
				_url = "/logistics/internaltrade/save.do";
				data=data.replace("&ID=",""); //在新增保存的时候不需要传入ID值
			} else {
				_url = "/logistics/internaltrade/update.do";
			}
			_url = RemoteLinkAddress + _url;
			$.post(_url, data,
				function(result) {
					console.log(result);
					if(result.msg == "success") {
						// reload the user data
						var parentLocation;
						parentLocation = searchParent("BasicInformationInternalProductGradingList.html");
						parentLocation.dialogClose();
						$.messager.alert({ // show error message
							title: '成功',
							msg: '添加成功'
						});
					} else {
						$.messager.alert({ // show error message
							title: '错误',
							msg: "输入的数据已存在数据库"
						});
					}
				},
				'json');
		}

		function AddInsideProductTypeName() {
			var pLocation = "UI/Market/DictData/DictDataAdd.html?id=internaltradetype";
			$("#ifrmEdit").attr("src", pLocation);
			constructcomboDialog($("#dlg"), "添加内部商品类型", $("#cc"));
			AddDialog.dialog('open');
		}
	</script>